package com.zprmb.udzt.activity;

import android.content.Intent;
import android.content.SharedPreferences.Editor;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.FragmentManager;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.zprmb.udzt.BaseActivity3;
import com.zprmb.udzt.MainActivity;
import com.zprmb.udzt.R;
import com.zprmb.udzt.Set_tr_pw;
import com.zprmb.udzt.V6LoginActivity;
import com.zprmb.udzt.V6WebviewChild;
import com.zprmb.udzt.util.Constant;
import com.zprmb.udzt.util.GuideAlertDialog;
import com.zprmb.udzt.util.GuideAlertDialog.OnSureClickListener;
import com.zprmb.udzt.util.LogUtils;
import com.zprmb.udzt.util.MySharePreferenceUtil;
import com.zprmb.udzt.util.NumUtil;
import com.zprmb.udzt.util.VolleryUtil;
import com.zprmb.udzt.view.RulerView;
import com.zprmb.udzt.view.RulerView.OnScaleListener;

import org.json.JSONObject;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

public class V6ZhitouIndexActivity extends BaseActivity3 implements OnClickListener, OnSureClickListener {
    long minute = 0;
    long second = 0;
    long hour = 0;
    TimerTask timerTask;
    private Timer timer;
    private FragmentManager fm;
    private RulerView rulerView;
    DecimalFormat df = new DecimalFormat("###0.0000");
    DecimalFormat df2 = new DecimalFormat("###0.00");
    private List<String> list = new ArrayList<String>();
    private TextView feature1, feature2, feature3;
    private String id, url, desc = "";
    private Button btn_dexterity_invest;
    private TextView et_amount;
    private ImageView iv_v4_nonetwork;
    private TextView tv_every_day, tv_year;
    private boolean flag;
    private int increaseNum = 0;
    private int remainAmount;
    private TextView tv_title;
    private ImageView img_ico;
    private ImageView img_share;
    private TextView tv_remain;
    //		private RelativeLayout rl_activity;
    private TextView tv_desc;
    private LinearLayout li_invest;
    private boolean islogin;
    private ImageView img_de_hand;
    private String type;
    private GuideAlertDialog mAlertDialog;
    private TextView v6_de_rate_dwon, v6_de_rate_up;
    private TextView tv_millionAccrua;
    private Double millionAccrua = (double) 0, rate = (double) 0;
    private String ref = "", linkurl;
    private LinearLayout v6_home_clock;
    private TextView tv_in_status;
    private RelativeLayout rl_menu;
    private LinearLayout li_status_all;
    private TextView tv_v6_productdetails_hour, tv_v6_productdetails_min, tv_v6_productdetails_second;
    private PopupWindow pop;
    private LinearLayout layout_calculator, layout_share;
    private RelativeLayout relatelayout_all;
    private ImageView iv_v4_nonetwork1;
    Handler handler2 = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            // TODO Auto-generated method stub
            super.handleMessage(msg);
            if (msg.what == 0) {
                countdwon();


            }
        }
    };
    String token;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_productnew);
//        setContentInview(V6DexterityActivity.this).setVisibility(View.INVISIBLE);
//		setImmersionStatus();
        ref = getShare().getString("usercode", "");
//		rl_activity=(RelativeLayout)findViewById(rl_activity);
        iv_v4_nonetwork = (ImageView) findViewById(R.id.iv_v4_nonetwork);
        tv_desc = (TextView) findViewById(R.id.tv_desc);
        li_status_all = (LinearLayout) findViewById(R.id.li_status_all);
        li_invest = (LinearLayout) findViewById(R.id.li_invest);
        tv_in_status = (TextView) findViewById(R.id.tv_in_status);
        tv_title = (TextView) findViewById(R.id.tv_title);
        img_share = (ImageView) findViewById(R.id.img_share);
        img_ico = (ImageView) findViewById(R.id.img_ico);
        feature1 = (TextView) findViewById(R.id.feature1);
        feature2 = (TextView) findViewById(R.id.feature2);
        feature3 = (TextView) findViewById(R.id.feature3);
        rl_menu = (RelativeLayout) findViewById(R.id.rl_menu);
        v6_home_clock = (LinearLayout) findViewById(R.id.v6_home_clock);
        tv_v6_productdetails_hour = (TextView) findViewById(R.id.tv_v6_productdetails_hour);
        tv_v6_productdetails_min = (TextView) findViewById(R.id.tv_v6_productdetails_min);
        tv_v6_productdetails_second = (TextView) findViewById(R.id.tv_v6_productdetails_second);
        img_de_hand = (ImageView) findViewById(R.id.img_de_hand);
        tv_every_day = (TextView) findViewById(R.id.tv_accumulated_earnings);
        tv_year = (TextView) findViewById(R.id.available_Balance);
        et_amount = (TextView) findViewById(R.id.et_amount);
        v6_de_rate_up = (TextView) findViewById(R.id.v6_de_rate_up);
        v6_de_rate_dwon = (TextView) findViewById(R.id.v6_de_rate_dwon);
        tv_remain = (TextView) findViewById(R.id.tv_remain);
        tv_millionAccrua = (TextView) findViewById(R.id.tv_millionAccrua);
        btn_dexterity_invest = (Button) findViewById(R.id.btn_dexterity_invest);
        btn_dexterity_invest.setVisibility(View.INVISIBLE);
        btn_dexterity_invest.setOnClickListener(this);
        View view = LayoutInflater.from(this)
                .inflate(R.layout.v6_pop_item, null);
        layout_calculator = (LinearLayout) view.findViewById(R.id.layout_calculator);
        layout_share = (LinearLayout) view.findViewById(R.id.layout_share);
        pop = new PopupWindow(view, LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        pop.setOutsideTouchable(true);
        pop.setBackgroundDrawable(new BitmapDrawable());
        rulerView = (RulerView) findViewById(R.id.ruler_view);
        token = (String) MySharePreferenceUtil.get(V6ZhitouIndexActivity.this, "mytoken", "");

//        MySharePreferenceUtil.put(MainActivity.this, "intentflag", "2");
        try {
            token = URLEncoder.encode(token, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        rulerView.setGravity(Gravity.BOTTOM);
        rulerView.setIndicatePadding(10);
        mAlertDialog = new GuideAlertDialog(this, this);
        if (getShare().getInt("hand", 0) == 0) {
            img_de_hand.setVisibility(View.VISIBLE);
        }
        rl_menu.setOnClickListener(this);
        layout_calculator.setOnClickListener(this);
        layout_share.setOnClickListener(this);
        img_share.setOnClickListener(this);
        img_ico.setOnClickListener(this);
        tv_title.setOnClickListener(this);
//		Typeface mtf = Typeface.createFromAsset(getAssets(),
//                "fonts/pen_kaishu.ttf");
//		rate_of_return.setTypeface(mtf);
//		wv.setWaveColor(Color.parseColor("#3CFFFFFF"), Color.parseColor("#3CFFFFFF"));

        rulerView.post(new Runnable() {
            @Override
            public void run() {

                rulerView.smoothScrollTo(1);
//                rulerView.setend(500000);
            }
        });
        rulerView.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
                if (img_de_hand.getVisibility() == View.VISIBLE) {
                    img_de_hand.setVisibility(View.GONE);
                    Editor editor = getShare().edit();
                    editor.putInt("hand", 1);
                    editor.commit();
                }
                return false;
            }
        });
        rulerView.setOnScaleListener(new OnScaleListener() {

            @Override
            public void onScaleChanged(int scale) {
                // TODO Auto-generated method stub
                Log.e("tag", scale + "");

                et_amount.setText(scale * increaseNum + "");
                if (scale < 1) {
                    rulerView.smoothScrollTo(1);
                }

//		tv_every_day.setText(df.format((scale*increaseNum)*millionAccrua/10000)+"");
//		tv_year.setText(df2.format((scale*increaseNum)*rate/100)+"");
            }
        });
//		fm=getSupportFragmentManager();
//
//		FragmentTransaction transaction=fm.beginTransaction();
//		 transaction.add(R.id.li_bill,DexterityFragment.newInstance(0, "tab"));
//		 transaction.commit();

        relatelayout_all = (RelativeLayout) findViewById(R.id.relatelayout_all);
        iv_v4_nonetwork1 = (ImageView) findViewById(R.id.iv_v4_nonetwork1);
        iv_v4_nonetwork1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                initData(true);
            }
        });

        if (!network()) {
            relatelayout_all.setVisibility(View.GONE);
            iv_v4_nonetwork1.setVisibility(View.VISIBLE);
        } else {
            relatelayout_all.setVisibility(View.VISIBLE);
            iv_v4_nonetwork1.setVisibility(View.GONE);
            initData(true);
        }


    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // TODO Auto-generated method stub
        return false;
    }

    private void shareLogin() {
        VolleryUtil vollery = new VolleryUtil() {

            @Override
            public void onUpDate(JSONObject jsonObject) {
                // TODO Auto-generated method stub
                if (jsonObject.optInt("success") == 1) {
                    pop.dismiss();
                    LogUtils.e(V6ZhitouIndexActivity.this, jsonObject.toString());
                    JSONObject json1 = jsonObject.optJSONObject("data");

                    if (getShare().getString("usercode", "").equals("")) {
                        linkurl = json1.optString("linkUrl");

                    } else {
                        linkurl = json1.optString("linkUrl") + "?ref=" + getShare().getString("usercode", "");

                    }
                    share(V6ZhitouIndexActivity.this,
                            json1.optString("description"),
                            json1.optString("title"),
                            linkurl,
                            json1.optString("imageUrl"));
                }
            }

            @Override
            public void onError() {
                // TODO Auto-generated method stub

            }
        };

        vollery.setHeaders("token", getToken());
        vollery.setHeaders("client", "android");
        vollery.setShow(true);
        vollery.setRequestMethod(0);
        vollery.execute(V6ZhitouIndexActivity.this, Constant.URL
                + "/api/shareProductContent/" + type + "/" + "ztb", "");
    }

    private void userinfo() {
        VolleryUtil volleryUtil = new VolleryUtil() {

            @Override
            public void onUpDate(JSONObject jsonObject) {
                // TODO Auto-generated method stub
                if (jsonObject.optInt("success") == 1) {
                    Intent intent = null;
                    JSONObject json = jsonObject.optJSONObject("data");
                    if ("false".equals(json.optString("isLogin"))) {
                        mAlertDialog.show();
                        mAlertDialog.setText("投资前请登录～");
                        mAlertDialog.setTitle("提示");
                        mAlertDialog.setType("login");
                        mAlertDialog.setButtonCancel("稍后");
                        mAlertDialog.setButtonsure("登录");

                        return;

                    }
                    if ("false".equals(json.optString("isIdAuth"))) {
                        mAlertDialog.show();
                        mAlertDialog.setText("投资前请先绑定银行卡～");
                        mAlertDialog.setTitle("提示");
                        mAlertDialog.setType("bindcard");
                        mAlertDialog.setButtonCancel("稍后");
                        mAlertDialog.setButtonsure("绑定银行卡");

                        return;
                    }
                    if ("false".equals(json.optString("isSetPayPwd"))) {
                        mAlertDialog.show();
                        mAlertDialog.setText("投资前请先设置交易密码～");
                        mAlertDialog.setTitle("提示");
                        mAlertDialog.setType("password");
                        mAlertDialog.setButtonCancel("稍后");
                        mAlertDialog.setButtonsure("设置交易密码");
                        return;
                    }
                    if ("false".equals(json.optString("isRiskAssessment"))) {
                        mAlertDialog.show();
                        mAlertDialog.setText("投资前请先风险测评～");
                        mAlertDialog.setTitle("提示");
                        mAlertDialog.setType("ceping");
                        mAlertDialog.setButtonCancel("稍后");
                        mAlertDialog.setButtonsure("风险测评");
                        return;
                    }
//                    intent = new Intent(V6ZhitouIndexActivity.this, V6DexterityPayInActivity.class);
                    intent = new Intent(V6ZhitouIndexActivity.this, V6NewZhiTouDexterityPayInActivity.class);
                    intent.putExtra("investamount", Integer.parseInt(et_amount.getText().toString()));
                    startActivity(intent);

                    /*
                   if (Integer.parseInt(et_amount.getText().toString())==0){
                        Toast.makeText(V6ZhitouIndexActivity.this, "转入金额不能为0", Toast.LENGTH_SHORT).show();
                    }else {

                    }*/


                }
//						


                else {

                }

            }

            @Override
            public void onError() {
                // TODO Auto-generated method stub

            }
        };
        volleryUtil.setRequestMethod(0);
        volleryUtil.setShow(true);
        volleryUtil.setHeaders("token", getToken());
        volleryUtil.execute(V6ZhitouIndexActivity.this, Constant.URL + "/api/v6/render/intelliDeposit", "");
    }

    private void initData(boolean show) {
        // TODO Auto-generated method stub
        VolleryUtil volleryUtil = new VolleryUtil() {

            @Override
            public void onUpDate(JSONObject jsonObject) {
                // TODO Auto-generated method stub


                LogUtils.e(V6ZhitouIndexActivity.this, "智投宝" + jsonObject.toString());
                if (jsonObject.optInt("success") == 1) {
//                    setContentInview(V6DexterityActivity.this).setVisibility(View.VISIBLE);
                    relatelayout_all.setVisibility(View.VISIBLE);
                    iv_v4_nonetwork1.setVisibility(View.GONE);
                    btn_dexterity_invest.setVisibility(View.VISIBLE);
                    li_invest.setVisibility(View.VISIBLE);
                    iv_v4_nonetwork.setVisibility(View.GONE);
                    JSONObject json1 = jsonObject.optJSONObject("data");
//					JSONObject json2=json1.optJSONObject("activityDesc");		
                    Gson gson = new Gson();
                    type = json1.optString("productType");
                    list = gson.fromJson(json1.optString("characterList"), new TypeToken<ArrayList<String>>() {
                    }.getType());
                    increaseNum = json1.optInt("increaseNum");
                    rulerView.setTextIncreaseNum(increaseNum);
//                    rulerView.setend(500000);
                    if ("downCount".equals(json1.optString("intelliStatus"))) {
                        btn_dexterity_invest.setBackgroundResource(R.drawable.btn_unclick);
                        long now = json1.optLong("now");
                        long end = json1.optLong("openDate");
                        long keyong = end - now;
                        li_status_all.setVisibility(View.VISIBLE);
                        tv_in_status.setVisibility(View.VISIBLE);
                        tv_in_status.setText("距离开放还剩 ");
                        countdwoninit(keyong);
                        btn_dexterity_invest.setText("即将开放");
                        btn_dexterity_invest.setEnabled(false);
                    } else if ("opening".equals(json1.optString("intelliStatus"))) {
                        li_status_all.setVisibility(View.GONE);
                        btn_dexterity_invest.setBackgroundResource(R.drawable.v6button);
                        btn_dexterity_invest.setText("转入");
                        btn_dexterity_invest.setEnabled(true);
                    } else {
                        li_status_all.setVisibility(View.VISIBLE);
                        v6_home_clock.setVisibility(View.GONE);
                        tv_in_status.setText("每日" + json1.optString("openTime") + "开放");
                        btn_dexterity_invest.setBackgroundResource(R.drawable.btn_unclick);
                        btn_dexterity_invest.setText("已售罄");
                        btn_dexterity_invest.setEnabled(false);
                    }
                    if (list.size() >= 3) {
                        feature1.setText(list.get(2).replace("#", "\n"));
                        feature2.setText(list.get(1).replace("#", "\n"));
                        feature3.setText(list.get(0).replace("#", "\n"));
                    }

                    v6_de_rate_up.setText(json1.optString("rateUp"));
                    v6_de_rate_dwon.setText(json1.optString("rateDown"));
                    tv_every_day.setText(json1.optString("betweenProfit"));
                    millionAccrua = json1.optDouble("millionAccrual");
                    tv_millionAccrua.setText("日均万元收益：" + millionAccrua + "元");
                    tv_year.setText(json1.optString("holdCap"));
                    rate = json1.optDouble("rate");

                    tv_remain.setText(NumUtil.getQian(json1.optString("remainAmount")));

                    id = json1.optString("productId");
                    flag = json1.optBoolean("flagFresh");


                } else if (jsonObject.optString("comment").equals("please login")) {
                    Intent intent = new Intent(V6ZhitouIndexActivity.this,
                            V6LoginActivity.class);
                    intent.putExtra("close", 1);
                    startActivity(intent);
                } else {
                    relatelayout_all.setVisibility(View.GONE);
                    iv_v4_nonetwork1.setVisibility(View.VISIBLE);
                }

            }

            @Override
            public void onError() {

                relatelayout_all.setVisibility(View.VISIBLE);
                iv_v4_nonetwork1.setVisibility(View.GONE);

            }
        };
        volleryUtil.setRequestMethod(0);
        volleryUtil.setShow(show);
        volleryUtil.setHeaders("token", token);
        volleryUtil.execute(V6ZhitouIndexActivity.this, Constant.URL + "/api/v6/render/intelliDeposit", "");
    }

    private void userinfo2() {
        VolleryUtil volleryUtil = new VolleryUtil() {

            @Override
            public void onUpDate(JSONObject jsonObject) {
                Log.d(jsonObject.toString(), "3333333333333333");

                // TODO Auto-generated method stub
                if (jsonObject.optInt("success") == 1) {

                } else {
                    if (jsonObject.optString("comment").equals("please login")) {
//						Editor ed=sha.edit();
//						ed.putInt("islogin", 0);
//						ed.commit();
                        Log.e("login", jsonObject.toString());
                        startActivity(new Intent(V6ZhitouIndexActivity.this, V6LoginActivity.class));


                    } else {
//                        Toast.makeText(V6ZhitouIndexActivity.this, jsonObject.optString("comment"), 2000).show();
                    }
                }

            }

            @Override
            public void onError() {
                // TODO Auto-generated method stub

            }
        };

        Log.d("------------token", V6LoginActivity.token);
        volleryUtil.setHeaders("token", token);
        volleryUtil.setRequestMethod(0);
        volleryUtil.execute(V6ZhitouIndexActivity.this, Constant.URL + "/api/v5/user/accountCenter", "");
    }


    private void countdwoninit(long time) {
        long keyong = time;
//		btn.setBackgroundResource(R.drawable.my_button);
//		btn.setText("马上投资");
//		checkBox.setEnabled(true);
        long day = keyong / (24 * 60 * 60 * 1000);
        long hour = (keyong / (60 * 60 * 1000) - day * 24);
        long min = ((keyong / (60 * 1000)) - day * 24 * 60 - hour * 60);
//		long hour = 0;
//		long min = 0;
        @SuppressWarnings("unused")
        long s = (keyong / 1000 - day * 24 * 60 * 60 - hour
                * 60 * 60 - min * 60);
//		long s=10;
        // long ms = (keyong - day * 24 * 60 * 60 * 1000 - hour*
        // 60 * 60 * 1000 - min * 60 * 1000 - s * 1000);
        // System.out.println(day + "天" + hour + "小时" + min +
        // "分"+ s + "秒" + ms + "毫秒");

        if (hour >= 10) {
            tv_v6_productdetails_hour.setText(hour + "");
        } else {
            tv_v6_productdetails_hour.setText("0" + hour);
        }

        tv_v6_productdetails_min.setText(min + "");
        tv_v6_productdetails_second.setText("" + s);
        this.hour = hour;
        minute = min;
        second = s;
        timerTask = new TimerTask() {

            @Override
            public void run() {
                Message msg = new Message();
                msg.what = 0;
                handler2.sendMessage(msg);
            }
        };

        if (timer == null) {

            timer = new Timer();
            timer.schedule(timerTask, 0, 1000);
        }
    }

    private void setImmersionStatus() {
        if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
            // 透明状态栏
            getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
            // 透明导航栏
            //getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        if (list.isEmpty()) {
            initData(false);
            userinfo2();
        } else {
            list.clear();
            initData(false);
            userinfo2();
        }


//	userinfo();
//	setdisappear_bottom_in(V6DexterityActivity.this, li_invest);

    }

   /* @Override
    public void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();

//		if(helper!=null){
//			helper.cancel();
//			wv.destroyDrawingCache();
//		}
    }*/

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        Intent intent = null;
        switch (v.getId()) {
            case R.id.btn_dexterity_invest:

                userinfo();
                break;
            case R.id.img_share:


                pop.showAsDropDown(img_share);

//				
//			}
                Log.e("pop", pop.isShowing() + "" + pop);
                break;
            case R.id.img_ico:
                intent = new Intent(V6ZhitouIndexActivity.this, V6WebviewChild.class);
                intent.putExtra("url", Constant.URL + "h5/helpCurrent?app=true&token=");
                intent.putExtra("title", "智投宝");
                startActivity(intent);
                break;
            case R.id.tv_title:
                intent = new Intent(V6ZhitouIndexActivity.this, V6WebviewChild.class);
                intent.putExtra("url", Constant.URL + "h5/helpCurrent?app=true&token=");
                intent.putExtra("title", "智投宝");
                startActivity(intent);
                break;
            case R.id.layout_share:
                shareLogin();
                break;
            case R.id.rl_menu:
//			WindowManager manager2=(WindowManager) getSystemService(Context.WINDOW_SERVICE);
//			@SuppressWarnings("deprecation")
//			//获取xoff
//			int xpos1 =manager2.getDefaultDisplay().getWidth()/2-pop.getWidth()/2;
                pop.showAsDropDown(img_share);
//                startActivity(new Intent(V6ZhitouIndexActivity.this, LoadingActivity.class));
                break;
            case R.id.layout_calculator:
                intent = new Intent(V6ZhitouIndexActivity.this, V6WebviewChild.class);
                intent.putExtra("url", Constant.URL + "h5/calculator?app=true&token=");
                intent.putExtra("title", "智投宝");
                startActivity(intent);
                pop.dismiss();
//			ToastUtil.showCenterToast(V6DexterityActivity.this, "计算器");
                break;

        }
    }

    @Override
    public void onConfirm() {
        // TODO Auto-generated method stub
//		ToastUtil.showCenterToast(V6DexterityActivity.this, "去操作");
        //需求量不大 暂且不使用枚举
        Intent intent = null;
        switch (mAlertDialog.getType()) {

            case "bindcard":
                intent = new Intent(V6ZhitouIndexActivity.this,
                        V6WebviewChild.class);
                intent.putExtra("url", Constant.URL + "h5/account/bankcard/bind/view?app=true&token=");
                intent.putExtra("title", "智投宝");
                startActivity(intent);
                break;
            case "password":
                intent = new Intent(V6ZhitouIndexActivity.this,
                        Set_tr_pw.class);
                startActivity(intent);
                break;
            case "ceping":
                Intent intent0 = null;

                intent0 = new Intent(V6ZhitouIndexActivity.this, V6WebviewChild.class);
                intent0.putExtra("url", Constant.URL + "h5/assess/index" + "?showHeader=1&app=true&token=");
                // intent0.putExtra("url",
                // "h5/assess/index?showHeader=1"+"?app=true&token=");
                // intent0.putExtra("flag", 1);
                // intent2.putExtra("url",
                // "/h5/messageCenter?app=true&token="+getToken());
//			intent0.putExtra("share", 1);
//			intent0.putExtra("titleview", 0);
//			intent0.putExtra("title", "风险测评");
                startActivity(intent0);
                break;
            case "login":
                intent = new Intent(V6ZhitouIndexActivity.this,
                        V6LoginActivity.class);
                intent.putExtra("close", 1);

                startActivityForResult(intent, 1);
                break;
        }
//		
//		intent = new Intent(V6DexterityActivity.this,
//				V6WebviewChild.class);
//		intent.putExtra("url", Constant.URL+"/h5/setTraPwd?app=true&token=");
//		intent.putExtra("title", "智投宝");
//		startActivity(intent);
    }

    private void countdwon() {
        if (minute == 0) {
            if (second == 0) {

                if (hour == 0) {
                    if (timer != null) {
                        timer.cancel();
                        timer = null;
                    }
                    if (timerTask != null) {
                        timerTask = null;
                    }
                    li_status_all.setVisibility(View.GONE);
//					tv_zhitou_status.setBackgroundResource(R.drawable.bianqian);
                    btn_dexterity_invest.setBackgroundResource(R.drawable.v6button);
                    btn_dexterity_invest.setText("转入");
                } else {


                }

            } else {
                second--;
                if (second == 0) {
                    if (hour != 0) {
                        hour--;
                        second = 59;
                        minute = 59;
                    }
                }
                if (hour > 10) {
                    tv_v6_productdetails_hour.setText(hour + "");

                } else {
                    // timeView.setText("0"+minute + ":0" + second);
                    tv_v6_productdetails_hour.setText("0" + hour);

                }
                if (second >= 10) {
                    // timeView.setText("0"+minute + ":" + second);
                    tv_v6_productdetails_min.setText("0" + minute);
                    tv_v6_productdetails_second.setText(second + "");
                } else {
                    // timeView.setText("0"+minute + ":0" + second);
                    tv_v6_productdetails_min.setText("0" + minute);
                    tv_v6_productdetails_second.setText("0" + second);
                }
            }
        } else {
            if (second == 0) {
                second = 59;
                minute--;
                if (minute >= 10) {
                    // timeView.setText(minute + ":" + second);
                    tv_v6_productdetails_min.setText(minute + "");
                    tv_v6_productdetails_second.setText(second + "");
                } else {
                    // timeView.setText("0"+minute + ":" + second);
                    tv_v6_productdetails_min.setText("0" + minute);
                    tv_v6_productdetails_second.setText(second + "");
                }
            } else {
                second--;
                if (second >= 10) {
                    if (minute >= 10) {
                        // timeView.setText(minute + ":" + second);
                        tv_v6_productdetails_min.setText(minute
                                + "");
                        tv_v6_productdetails_second
                                .setText(second + "");
                    } else {
                        // timeView.setText("0"+minute + ":" + second);
                        tv_v6_productdetails_min.setText("0"
                                + minute);
                        tv_v6_productdetails_second
                                .setText(second + "");
                    }
                } else {
                    if (minute >= 10) {
                        // timeView.setText(minute + ":0" + second);
                        tv_v6_productdetails_min.setText(minute
                                + "");
                        tv_v6_productdetails_second.setText("0"
                                + second);
                    } else {
                        // timeView.setText("0"+minute + ":0" + second);
                        tv_v6_productdetails_min.setText("0"
                                + minute);
                        tv_v6_productdetails_second.setText("0"
                                + second);

                    }
                }
            }
        }
    }

    @Override
    public void onCancle() {
        // TODO Auto-generated method stub
//		ToastUtil.showCenterToast(V6DexterityActivity.this, "取消");
    }
}
